//
//  FirstViewController.m
//  RCA24
//
//  Created by Raul Pacurar on 2/4/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "HomeViewController.h"

@implementation HomeViewController

@synthesize appointmentButton;
@synthesize infoButton;
@synthesize asistentaButton;
@synthesize contactButton;

@synthesize  bannerImageView;

@synthesize logoImageView;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = NSLocalizedString(@"Home", @"Home");
        self.tabBarItem.image = [UIImage imageNamed:@"home"];
    }
    return self;
}
							
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
	
    bannerImageView.animationImages=[NSArray arrayWithObjects:[UIImage imageNamed:@"buy.jpg"],[UIImage imageNamed:@"quote.jpg"],nil];
    
    UIImage * backgroundPattern = [UIImage imageNamed:@"bg-app.png"];
    [self.view setBackgroundColor:[UIColor colorWithPatternImage:backgroundPattern]];
    
    bannerImageView.animationDuration=3.0;
    bannerImageView.animationRepeatCount=0;
    [bannerImageView startAnimating];
    [self.view addSubview:bannerImageView];
    [bannerImageView release];
    
    
    CALayer * l = [logoImageView layer];
    l.cornerRadius = 8.0f;
    l.masksToBounds = YES;
    
    CALayer * l1 = [bannerImageView layer];
    l1.cornerRadius = 8.0f;
    l1.masksToBounds = YES;


}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
	[super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
	[super viewDidDisappear:animated];
}

- (void) dealloc
{
    [super dealloc];
    
    [appointmentButton release];
    [infoButton release];
    [asistentaButton release];
    [contactButton release];
    
    [bannerImageView release];
    
    [logoImageView release];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

- (IBAction) buttonPressed: (id) sender
{
    if(sender == appointmentButton)
    {
        self.tabBarController.selectedIndex = 1;
    }
    else if(sender == infoButton)
    {
        self.tabBarController.selectedIndex = 2;
    }
    else if(sender == asistentaButton)
    {
        self.tabBarController.selectedIndex = 3;
    }
    else if(sender == contactButton)
    {
        self.tabBarController.selectedIndex = 4;
    }
}

@end
